<template>
  <el-table class="custom-user-table" :data="userList" border stripe>
    <el-table-column prop="mobile" label="电话" width="150px"></el-table-column>
    <el-table-column prop="last_login_time" label="最近登录日期" width="150px">
      <template slot-scope="scope">{{ scope.row.last_login_time | formatDate }}</template>
    </el-table-column>
    <el-table-column prop="last_login_ip" label="最近登录IP"></el-table-column>
    <el-table-column prop="register_time" label="注册日期" width="150px">
      <template slot-scope="scope">{{ scope.row.register_time | formatDate }}</template>
    </el-table-column>
    <el-table-column prop="register_ip" label="注册IP"></el-table-column>
  </el-table>
</template>

<script>
export default {
  name: 'UserTable',
  props: {
    userList: {
      type: Array,
      default () {
        return []
      }
    }
  },
  filters: {
    formatDate (value) {
      const date = new Date(value)
      const year = date.getFullYear()
      const month = (date.getMonth() + 1 + '').padStart(2, '0')
      const day = (date.getDate() + '').padStart(2, '0')
      return `${year}-${month}-${day}`
    }
  },
  methods: {
    // 监听子组件发射的事件，获得最新的tradeList和total信息
    updateUserList () {
      this.$emit('user-list')
    }
  }
}
</script>

<style scoped>

</style>
